﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data.SqlClient;
using System.Data;
using System.Collections;
using System.Drawing;
using System.Drawing.Drawing2D;
using DataAccess;

namespace BusinessLogic
{
    public static class LayLoaiTKKT
    {
        private static SqlCommand cmd;
        private static ArrayList arr;
        private static SqlDataReader dr;
        private static SqlConnection cn;
     

        public static Entities.GiaTriCombox[] sp_Select_TKKT(Entities.GiaTriCombox combox)
        {
            Entities.GiaTriCombox[] list = null;
            try
            {
                
                cn = DataAccess.Connection.OpenConnection();
                cmd = new SqlCommand(Common.Constants.LayCombox.sp_LayTKKT, cn);
                cmd.Parameters.Add(Common.Constants.LayCombox.HanhDong, SqlDbType.VarChar).Value = combox.TenBang;
                dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                arr = new ArrayList();
                while (dr.Read())
                {
                    Entities.GiaTriCombox row = new Entities.GiaTriCombox();
                    row.TenCotKhoaChinh = dr[0].ToString();
                    row.TenCotTenHienThi = dr[1].ToString();
                    arr.Add(row);
                }
                int n = arr.Count;
                if (n == 0) { list = null; }
                list = new Entities.GiaTriCombox[n];
                for (int i = 0; i < n; i++)
                {
                    list[i] = (Entities.GiaTriCombox)arr[i];
                }
            }
            catch (Exception ex)
            { string s = ex.Message.ToString(); list = null; }
            finally
            {
                cmd.Connection.Dispose();
                cn.Close();
            }
            return list;
        }
    }
}
